-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bad sad error in SemanticAnalyzer #42796
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42796 +/- ##
=========================================
Coverage 77.26% 77.26%
- Complexity 51302 51303 +1
=========================================
Files 2929 2929
Lines 204423 204423
Branches 26668 26668
=========================================
+ Hits 157938 157940 +2
+ Misses 37896 37894 -2
Partials 8589 8589 ☔ View full report in Codecov by Sentry. |
@@ -1876,7 +1876,8 @@ private void handleDeclaredWithVar(BLangVariable variable, AnalyzerData data) { | |||
handleWildCardBindingVariable(simpleVariable, currentEnv); | |||
|
|||
long ownerSymTag = currentEnv.scope.owner.tag; | |||
if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET) { | |||
if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET || | |||
(ownerSymTag & SymTag.PACKAGE) == SymTag.PACKAGE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the variable is in the package scope, we define those variables in the symbol enter. Here, what we define are variables within functions, and the variables' owner becomes let. In the following scenario, the owner tag should also be equal to let.
In the current implementation, we set the owner as package
instead of let
. This is the root cause of the issue.
type Student record {|
string fname;
string lname;
int id;
|};
Student[] students = [];
var v1 = from var st in students
let var name = st.fname + st.lname
select name;
function testModuleLevelLetClause() {
var v2 = from var st in students
let var name = st.fname + st.lname
select name;
}
@mindula It's better to change the title to reflect the specific issue we are fixing. As we tag these issues in the release notes, this will provide better understanding to users when they check for changes in the new update. |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the |
Purpose
$title.
Fixes #41101
Approach
Samples
Remarks
Check List